import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // 英文版elements-ui

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control

import components from './components' // 引入所有全局组建
import * as directives from '@/directives' // 导入所有自定义指令
import * as filters from '@/filters' // 导入所有过滤器
import checkPermission from '@/mixin' // 引入全局混入

if (process.env.NODE_ENV === 'production') {
  const { mockXHR } = require('../mock')
  mockXHR()
}

// 注册所有的自定义指令
Object.keys(directives).forEach((item) => {
  Vue.directive(item, directives[item])
})

// 注册所有的过滤器
Object.keys(filters).forEach((key) => {
  Vue.filter(key, filters[key])
})

// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI, { locale }) // 英文版声明
Vue.use(ElementUI)
Vue.use(components)
Vue.mixin(checkPermission) // 注册全局混入

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: (h) => h(App)
})
